package com.ruoyi.common.enums;


import com.ruoyi.common.exception.ServiceException;
import lombok.Getter;

import java.util.Arrays;


@Getter
public enum BaseBooleanEnum implements BaseInteger{
    NO(0, "否"),
    YES(1, "是");

    private final Integer code;
    private final String desc;
    BaseBooleanEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    // 可选：每个枚举类可以定义自己的fromCode方法
    public static BaseBooleanEnum fromCode(Integer code) {
        return BaseInteger.fromCode(BaseBooleanEnum.class, code);
    }

    @Override
    public BaseBooleanEnum valOf(Integer code) {
        return Arrays.stream(BaseBooleanEnum.values()).filter(item -> item.code.equals(code)).findFirst().orElseThrow(() -> new ServiceException("枚举转换异常"));
    }
}
